import request from '@/utils/request';
const REGISTER_URL = '/applet/user/register'
const LOGIN_URL = '/applet/user/appletLogin'
const THIRDLOGIN_URL = ''
const CAROUSEL_URL = '/applet/user/carousel/list'


//设置请求白名单,即不需要带上token
request.whiteList = [
  REGISTER_URL,
  LOGIN_URL,
  CAROUSEL_URL,
]

//注册
export const Register = data => request(REGISTER_URL, {
  method: 'POST',
  showLoading: true,
  data,
  header: {
    'content-type': 'application/x-www-form-urlencoded'
  }
})

//登录
export const Login = data => request(LOGIN_URL, {
  // method:'POST',
  showLoading: true,
  params:data
})

export const ThirdLogin = data => request(THIRDLOGIN_URL, {
  method: 'POST',
  data
})

/*--------------轮播图-------------*/
export const GetBanner = () => request(CAROUSEL_URL)

/*--------------商品相关-------------*/
export const GetCategory = () => request('/applet/user/category/list')
export const GetGoodsList = (data) => request('/applet/user/goods/list', {
  params:data
})
export const GetHotGoods = (data) => request('/applet/user/goods/getHot', {
  params:data
})
export const GetGoodsDetail = data => request('/api/goods/getGoodsItem', {
  params:data
})
export const ExchangeGoods = data => request('/api/goods/exchange', {
  method: 'POST',
  data,
  headers: {
    'content-type': 'application/x-www-form-urlencoded'
  }
})
export const SubmitOrder = data => request('/api/goods/submitOrder', {
  method: 'POST',
  data
})

/*--------------订单-------------*/
export const GetOrder = () => request('/api/order/list')

/*--------------收货地址-------------*/
export const GetAllAddress = () => request('/api/address/getUserAddress')
export const UpdateAddress = (data) => request('/api/address/updateAddress', {
  method: 'POST',
  data,
  headers: {
    'content-type': 'application/x-www-form-urlencoded'
  }
})
export const AddAddress = (data) => request('/applet/personalCenter/addAddress', {
  method: 'POST',
  data,
  headers: {
    'content-type': 'application/x-www-form-urlencoded'
  }
})
export const GetDefault = () => request('/api/address/getDefault')
export const GetAddressDetail = data => request('/api/address/getAddressInfo', {
  params:data
})

/*--------------扫码-------------*/
export const QureyCode = data => request('/applet/personalCenter/queryFw', {
  params:data
})
export const ActiveCode = data => request('/applet/personalCenter/scanCode', {
  params:data,
})

/*--------------记录-------------*/
export const IntegralRecord = () => request('/applet/personalCenter/integralRecord')
export const PhysicalRecord = () => request('/applet/personalCenter/physicalRecord')